﻿@namespace Masa.Docs.Shared.Shared
@inherits NextTickComponentBase

<MNavigationDrawer Right="!RTL"
                   App
                   Class="default-toc py-6 pr-4"
                   Clipped
                   Floating
                   Touchless
                   Width="300">
    <PrependContent>
        <ErrorBoundary>
            <ChildContent>
                <GitHubIssues />
            </ChildContent>
            <ErrorContent>
            </ErrorContent>
        </ErrorBoundary>
    </PrependContent>

    <ChildContent>
        @if (_toc.Any())
        {
            <div class="toc-content mb-2 ml-6">@I18n.T("Toc")</div>
        }
        <ul class="mb-6">
            @foreach (var item in _toc)
            {
                var hash = $"#{item.Anchor}";

                <MScrollToTargetTrigger Target="@item.Anchor" @key="@item.Anchor">
                    @{
                        var color = context.IsActive ? "primary--text" : "secondary--text";
                    }

                    <li class="pl-3 text-body-2 py-1 font-weight-regular @GenClass(item) toc-li @color">
                        <a class="@($"m-toc-link d-block transition-swing text-decoration-none {color}")"
                           href="@hash"
                           @onclick="@context.ScrollToTarget"
                           @onclick:preventDefault>
                            @item.Content
                            @if (item.Attrs.ContainsKey("released-on"))
                            {
                                <MIcon Color="@AppService.ColorForNewState" Small>mdi-circle-medium</MIcon>
                            }
                            else if (item.Attrs.ContainsKey("updated-in"))
                            {
                                <MIcon Color="@AppService.ColorForUpdateState" Small>mdi-circle-medium</MIcon>
                            }
                        </a>
                    </li>
                </MScrollToTargetTrigger>
            }
        </ul>
        <Sponsors />
        <Contact />
    </ChildContent>
</MNavigationDrawer>
